package com.muyu.danmo.controller;

import com.muyu.common.core.domain.Result;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.LoginUser;
import com.muyu.danmo.service.IDanmoCommunityCommentLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 社区评论点赞Controller
 *
 * @author : kunzong
 * @date : 2024-11-19
 */
@RestController
@RequestMapping("/danmoCommunityCommentLike")
public class DanmoCommunityCommentLikeController {
    @Autowired
    private IDanmoCommunityCommentLikeService danmoCommunityCommentLikeService;

    /**
     * 社区评论点赞
     *
     * @param id
     * @return
     */
    @Log(title = "社区点赞", businessType = BusinessType.UPDATE)
    @PostMapping("/isCollect/{id}")
    public Result edit(@PathVariable Long id) {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        if (loginUser == null) {
            return Result.notLoggedIn("请登录");
        }
        return danmoCommunityCommentLikeService.isCollect(id);
    }
}
